<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //传统构造函数写法
        // function Person(name, age) {
        //     this.name = name
        //     this.age = age
        // }
        // Person.prototype.say = function () {
        //     console.log(this.name, this.age)
        // }
        // let obj = new Person("twj", 100)
        // console.log(obj)
        //ES6新写法
        let s = Symbol('say')
        class Person {
            constructor(name, age) {
                this.name = name
                this.age = age
            }
            hhh() {
                console.log("hhh")
            }
            [s]() {
                console.log(this.name, this.age)
            }
        }
        let obj = new Person("twj", 100)
        console.log(obj.__proto__ === Person.prototype) //true
        obj[s]() //twj 100
    </script>
</body>

</html>